﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
                
>
  <xsl:output method="xml" media-type="text/html" encoding="utf-8" />
  <xsl:param name="relrootpath"/>
  <xsl:template match="/LearningRequestContext">
    <xsl:variable name="ranum" select="generate-id(.)" />
   
    <Transform>

      <ContentToRender>
        <Template status="Pending">
          <Scripts>
            <Block name="scu-approvelearning">
              <script>
                function approvelearningrequest(requestid)
                {

                $.ajax({ type: 'POST',
                contentType: 'application/json',
                url: relRootPath + '/Mod/Learning/LearningWebService.asmx/ApproveLearningRequest',
                data: "{ 'requestId': '" + requestid + "' }",
                dataType: 'json',
                async: true,
                success: function(result)
                {
                location.reload();
                },
                error: function(result, status) {
                $(this).attr('disabled', false);
                }
                }
                );

                }

                function rejectlearningrequest(requestid)
                {
                $.ajax({ type: 'POST',
                contentType: 'application/json',
                url: relRootPath + '/Mod/Learning/LearningWebService.asmx/RejectLearingRequest',
                data: "{ 'requestId': '" + requestid + "' }",
                async: true,
                dataType: 'json',
                success: function(result)
                {
                location.reload();
                },
                error: function(result, status) {
                $(this).attr('disabled', false);
                }
                });
                }


                google.setOnLoadCallback(function()
                {
                $('.approvelearningbutton').click(function(){

                approvelearningrequest($(this).attr('rel'));
                disableactionbutton();
                });

                $('.rejectlearningbutton').click(function(){

                rejectlearningrequest($(this).attr('rel'));
                disableactionbutton();
                });

                });

                function disableactionbutton()
                {
                $('.actionbutton').attr('disabled', true).unbind('click');
                }


              </script>
            </Block>
          </Scripts>
          <Content>

            <div>
              <div>
                <control kind="userlink">
                  <xsl:attribute name="UserId">
                    <xsl:value-of select="RequestorUserId"/>
                  </xsl:attribute>
                </control>向你发出互助请求
              </div>
              <div class="ctn-p-t">
                "<xsl:value-of select="Comment"/>"
              </div>
              <div class="ctn-p-t">
                <a class="pointer opendetailslink">
                  <xsl:attribute name="rel">
                    <xsl:text>dialog-</xsl:text>
                    <xsl:value-of select="$ranum" />
                  </xsl:attribute>
                  详细信息
                </a>
                |
                <a class="approvelearningbutton pointer actionbutton">
                  <xsl:attribute name="rel">
                    <xsl:value-of select="RequestId"/>
                  </xsl:attribute>
                  同意请求
                </a>
                |
                <a class="rejectlearningbutton pointer actionbutton">
                  <xsl:attribute name="rel">
                    <xsl:value-of select="RequestId"/>
                  </xsl:attribute>
                  拒绝请求
                </a>
                <script>
                  google.setOnLoadCallback(function()
                  {
                  $('.<xsl:text>dialog-</xsl:text>
                  <xsl:copy-of select="$ranum" />').dialog(
                  {width:700, modal:true,draggable:false,closeOnEscape:true,autoOpen:false}
                  );

                  $('.opendetailslink').click(function(){
                  $('.'+$(this).attr('rel')).dialog('open');
                  });

                  $('.closedialogformbutton').click(function(){
                  $('.'+$(this).attr('rel')).dialog('close');
                  });

                  });
                </script>
              </div>
              <div title="互助信息" class="details-dialog">
                <xsl:attribute name="class">
                  <xsl:text>dialog-</xsl:text>
                  <xsl:copy-of select="$ranum" />
                </xsl:attribute>
                <strong>我的互助信息</strong>
                <control location="Shared" name="LearningProfileItem.ascx" kind="usercontrol" type="SharingCenter.Web.Shared.LearningProfileItem">
                  <properties>
                    <property name="LearningProfileId" type="System.Guid">
                      <xsl:attribute name="value">
                        <xsl:value-of select="RequesteeProfileId"/>
                      </xsl:attribute>
                    </property>
                    <property name="ShowButtons" value="false" type="System.Boolean" />
                    <property name="CssClass" value="learning-profile-b" type="System.String" />
                  </properties>
                </control>
                <strong>对方的互助信息</strong>
                <control location="Shared" name="LearningProfileItem.ascx" kind="usercontrol" type="SharingCenter.Web.Shared.LearningProfileItem">
                  <properties>
                    <property name="LearningProfileId" type="System.Guid">
                      <xsl:attribute name="value">
                        <xsl:value-of select="RequestorProfileId"/>
                      </xsl:attribute>
                    </property>
                    <property name="ShowButtons" value="false" type="System.Boolean" />
                    <property name="CssClass" value="learning-profile-b" type="System.String" />
                  </properties>
                </control>
                <div class="actionarea">
                  <a class="submitbutton closedialogformbutton">
                    <xsl:attribute name="rel">
                      <xsl:text>dialog-</xsl:text>
                      <xsl:value-of select="$ranum" />
                    </xsl:attribute>
                    确定
                  </a>
                </div>
              </div>
            </div>
          </Content>
        </Template>
        <Template status="Approved">
          <Content>
            <div>
              <strong>互助请求</strong>
              <div class="ctn-p-t">
                "<xsl:value-of select="Comment"/>"
              </div>
              <div class="r-app">
                你已经同意了该互助请求。
              </div>
              <div class="ctn-p-t">
                <a>
                  <xsl:attribute name="href">
                    <xsl:value-of select="$relrootpath"/>
                    <xsl:text>/Mod/Learning/MyLearning.aspx?id=</xsl:text>
                    <xsl:value-of select="LearningHistoryId"/>
                  </xsl:attribute>
                  查看详细
                </a>
              </div>
            </div>
            
          </Content>
        </Template>
        <Template status="Rejected">
          <Content>
            <div>
              <strong>互助请求</strong>
              <div class="hltext">
                <div class="nss ns-exclaim">
                  <xsl:text> </xsl:text>
                </div>
                <span class="iconlabel">你已拒绝了互助请求。</span>
              </div>
            </div>
          </Content>
        </Template>
      </ContentToRender>
      <ActionList>
        <Template status="Pending">
          <action webservicepath="" webmethod="" text="同意请求">
            <param name="requestid"></param>
          </action>
        </Template>
        <Template status="Rejected">

        </Template>
      </ActionList>
    </Transform>
  </xsl:template>
</xsl:stylesheet>
